package day2;

import java.io.*;

//缓冲流 + 新版try-catch实现文件复制
public class TestCopy3 {
    public static void main(String[] args) {
        try (
                FileInputStream fis = new FileInputStream("d://a//b//Newd.txt");
                FileOutputStream fos = new FileOutputStream("d://a//Newd.txt");
                BufferedInputStream bis = new BufferedInputStream(fis);
                BufferedOutputStream bos = new BufferedOutputStream(fos);
        ) {
            {
                long start = System.currentTimeMillis();
                byte[] bs = new byte[1024];
                int len = 0;
                while ((len = bis.read(bs)) != -1) {
                    bos.write(bs, 0, len);
                }
                long end = System.currentTimeMillis();
                System.out.println((end - start) + "ms");
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
